home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 27
/
Mac Magazin and MacEasy Magazine CD - Issue 27.iso
/
Grafik & Text
/
Sans-Faute⁄Grammaire ƒ
/
Adaptateurs
/
Sources des scripts (anglais)
/
Vérification WordPerfect® 3
< prev
Wrap
Text File
|
1996-02-20
|
3KB
|
87 lines
set kMaxDocSize to 10000 -- max number of characters of a document for checking it in one time
set kMaxCheckingSFG to 32000 -- max number of characters that Sans-Faute/Grammaire can check
set knbParagraphMaxToCheck to 25 -- max number of paragraphs sent to Sans-Faute/Grammaire
tell application "WordPerfect"
set FrontDocPresent to exists front document
end tell
if FrontDocPresent then
set endParagraphIdx to 0
tell application "WordPerfect"
set nbParagraph to count paragraph of front document
end tell
repeat while endParagraphIdx < nbParagraph
-- try to collect a maximum of paragraphs
set paragraphIdx to endParagraphIdx + 1
tell application "WordPerfect"
set paragraphSize to count character of paragraph paragraphIdx of front document
if paragraphSize = 1 then
set dummy to paragraph paragraphIdx of front document
set paragraphSize to count character of dummy
end if
end tell
if paragraphSize > kMaxCheckingSFG then
display dialog "Le paragraphe " & paragraphIdx & " dépasse 32000 caractères. Sans-Faute/Grammaire ne peut pas le vérifier !"
end if
repeat while (paragraphIdx ≤ nbParagraph) and (paragraphSize > kMaxCheckingSFG)
set paragraphIdx to paragraphIdx + 1
if paragraphIdx ≤ nbParagraph then
tell application "WordPerfect"
set paragraphSize to count character of paragraph paragraphIdx of front document
if paragraphSize = 1 then
set dummy to paragraph paragraphIdx of front document
set paragraphSize to count character of dummy
end if
end tell
if paragraphSize > kMaxCheckingSFG then
display dialog "Le paragraphe " & paragraphIdx & " dépasse 32000 caractères. Sans-Faute/Grammaire ne peut pas le vérifier !"
end if
end if
end repeat
set startParagraphIdx to paragraphIdx
set bunchSize to 0
set nbparagraphBunch to 0
set objToCheck to {}
repeat while (paragraphIdx ≤ nbParagraph) and (nbparagraphBunch < knbParagraphMaxToCheck) and (bunchSize + paragraphSize ≤ kMaxDocSize)
-- (paragraphSize ≤ kMaxCheckingSFG) is implicit
set bunchSize to bunchSize + paragraphSize
if paragraphSize > 0 then
set objToCheck to objToCheck & {a reference to the paragraph paragraphIdx of front document}
set nbparagraphBunch to nbparagraphBunch + 1
end if
set paragraphIdx to paragraphIdx + 1
if paragraphIdx ≤ nbParagraph then
tell application "WordPerfect"
set paragraphSize to count character of paragraph paragraphIdx of front document
if paragraphSize = 1 then
set dummy to paragraph paragraphIdx of front document
set paragraphSize to count character of dummy
end if
end tell
end if
end repeat
if (bunchSize = 0) and (paragraphIdx ≤ nbParagraph) and (paragraphSize ≤ kMaxCheckingSFG) then
set objToCheck to objToCheck & {a reference to the paragraph paragraphIdx of front document}
set endParagraphIdx to paragraphIdx
set bunchSize to paragraphSize
else
set endParagraphIdx to paragraphIdx - 1
end if
if bunchSize > 0 then -- cas be zero if the end of the document contains only paragraphs > 32000
-- tell Sans-Faute/Grammaire to check the content of the list of references and made changes in Application WordPerfect®
tell application "Sans-Faute/Grammaire 2"
Checking objToCheck ClientAddress Application "WordPerfect"
end tell
end if
end repeat
else
display dialog "Aucun document n'est ouvert dans WordPerfect® 3 !"
end if